$(function(){
	//根据窗口调整表格高度
    $(window).resize(function() {
        $('#mytab').bootstrapTable('resetView', {
            height: tableHeight()
        })
    })
    //生成数据
    $('#mytab').bootstrapTable({
    	method: 'post',
    	contentType: "application/x-www-form-urlencoded",
    	url:"../shop/lists.do",
    	height:tableHeight(),//高度调整
    	toolbar: '#toolbar',
    	striped: true, //是否显示行间隔色
    	dataField: "data",
    	pageNumber: 1, //初始化加载第一页，默认第一页
    	pagination:true,//是否分页
    	queryParamsType:'limit',
    	queryParams:queryParams,
    	sidePagination:'client',
    	pageSize:10,//单页记录数
    	pageList:[5,10,20,30],//分页步进值
    	showRefresh:true,//刷新按钮
    	showColumns:true,
    	clickToSelect: true,//是否启用点击选中行
    	toolbarAlign:'right',
    	buttonsAlign:'right',//按钮对齐方式
    	toolbar:'#toolbar',//指定工作栏
    	columns:[
        	{
        		title:'全选',
        		field:'select',
        		checkbox:true,
        		width:25,
        		align:'center',
        		valign:'middle'
        	},
        	{
        		title:'shopId',
        		field:'shopId',
        		visible:false
        	},
        	{
        		title:'店铺名称',
        		field:'shopName',
        		sortable:true
        	},
        	{
        		title:'店铺链接地址',
        		field:'shopUrl',
        		sortable:true
        	},
        	{
        		title:'店铺LOGO',
        		field:'shopLogo',
        	},
        	{
        		title:'wangwang',
        		field:'wangwang'
        	},
        	{
        		title:'注册日期',
        		field:'createTime',
        		sortable:true
        	},
        	{
        		title:'状态',
        		field:'status',
        		align:'center',
        		formatter:operateFormatter
        	}
    	],
    	locale:'zh-CN',//中文支持,
    })

   function operateFormatter(value,row,index){
    	if(value==2){
    		return '<i class="fa fa-lock" style="color:red"></i>'
    	}else if(value==1){
    		return '<i class="fa fa-unlock" style="color:green"></i>'
    	}else{
    		return '数据错误'
    	}
    }

    //请求服务数据时所传参数
    function queryParams(params){
    	return{
    		pageSize: params.limit,
    		pageIndex:params.pageNumber,
        shopName:$('#search_name').val(),
        wangwang:$('#search_wangwang').val(),
        platformId:$('#search_platformId').val()
    	}
    }
    //查询按钮事件
    $('#search_btn').click(function(){
    	$('#mytab').bootstrapTable('refresh', {url: '../shop/searchLists.do'});
    })
    

    //弹出框取消按钮事件
   　　$('.popup_de .btn_cancel').click(function(){
	   $('.popup_de').removeClass('bbox');
   　　})
    //弹出框关闭按钮事件
     $('.popup_de .popup_close').click(function(){
	   $('.popup_de').removeClass('bbox');
   　　})
})
function tableHeight() {
    return $(window).height() - 140;
}
